app.factory("$canceler", ["$q", "$timeout", function ($q, $timeout) {
    function CancelerService() {
    };

    CancelerService.prototype.create = function(durationMs){
        var duration = (durationMs || 5) * 1000;
        var canceler = $q.defer();
        $timeout(function () {
            canceler.resolve();
        }, duration);
        return canceler;
    }

    return new CancelerService();
} ]);